<!DOCTYPE html>
<html lang="en" xmlns:v-text="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<counter v-on:plus="" v-></counter>

</div>

<script type="text/javascript">
    const counter = {
        template:`
            <div>
            <button v-on:click="numPlus">增加</button>
            <button v-on:click="nunReduce">减少</button>

            </div>`,
        data(){
            return {num:1}
        },
        methods: {
            numPlus(){
                console.log("num"+this.num);
                return this.$emit("plus");

            },
            numReduce(){
                console.log("num"+this.num);
                return this.$emit("reduce");
            }
        }

    }
    Vue.component("counter",counter)
    var app = new Vue({
        el:"#app",
        data:{
            g_num:0
        },
        methods:{
            numPlus(){
                this.g_num++;
            },
            numReduce(){
                this.g_num--;
            }
        }
    });
</script>

</body>
</html>